package sort;

import java.util.Arrays;
import java.util.Random;

/*
十万个随机数
BubbleSort 13596 ms
SelectSort 3509 ms
InsertSort 699 ms
ShellSort  13ms
QuickSort  10ms
MergeSort  11ms

一百万随机数
InsertSort 66942ms
ShellSort  138ms
QuickSort  111ms
MergeSort  115ms
RadixSort  77ms
堆排序      104ms
一千万随机数
堆排序      1878ms
希尔排序    1826ms
QuickSort  1206ms
MergeSort  1336ms
RadixSort  807ms

一亿
RadixSort OutOfMemoryError
*/
public class SortTest {
    static final int SIZE=100;
    public static void main(String[] args) {
        int array[] = new int[SIZE];
        for (int i=0;i<SIZE;i++){
            array[i] = (int)(Math.random()*SIZE);
        }

        //System.out.println(Arrays.toString(array));
        //MySort sort = new BubbleSort();
        //MySort sort = new SelectSort();
        //MySort sort = new InsertSort();
        //MySort sort = new ShellSort();
        //MySort sort = new QuickSort();
        //MySort sort = new MergeSort();
        //MySort sort = new RadixSort();
        MySort sort = new HeapSort();
        long startMil = System.currentTimeMillis();
        sort.sort(array);
        long endMil = System.currentTimeMillis();
        System.out.println(endMil-startMil);
        System.out.println(Arrays.toString(array));
    }
}
